/**
 * @author chensj
 * @title
 * @email chensj@winning.com.cn
 * @package
 * @date: 2018-11-22 16:03
 */
const express = require('express');
const app = express();
const mssql = require('mssql');

const config = {
    user:'sa',
    password:'zaqwsx12!@',
    server:'172.17.1.214',
    database: 'CM_DataCenter',
    pool: {
        max: 10,
        min: 0,
        idleTimeoutMillis: 30000
    },
    options:{
        encrypt:false
    }
};

app.get('/',((req,res) => {
    mssql.connect(config).then(pool => {
       return pool.request()
           .input('input_parameter',mssql.Int,1)
       .query('select * from MBZ_DICT_INFO WHERE DICT_VALUE != @input_parameter')
    }).then(result => {
        console.dir(result);
        return pool.request()
            .input('input_parameter', sql.Int, 1)
            .output('output_parameter', sql.VarChar(50))
            .execute('procedure_name')
    }).then(result => {
        console.dir(result)
    }).catch(err => {
        // ... error checks
    });
    mssql.on('error', err => {
        // ... error handler
    })
    res.send('数据库连接成功');
}));

app.listen(3001,function () {
    console.log('app listening on 3001');
});